import { Component } from 'react';

import {ScrollList, Group, Tab, SearchBar, Toast, Button, Boxs, Popup, Dialog} from 'saltui';

const { HBox, Box,VBox} = Boxs;
import MyTabBar from 'components/tab_bar';
import Time from 'salt-icon/lib/Time';
import AngleRight from 'salt-icon/lib/AngleRight';

import './PageHome.less';
import { URLS, nodataIcon } from '../../../app/variables';
import DB from '../../../app/db';



const Item = React.createClass({
  clickList: function (event) {
    if(this.props.ableClick) {
      let processInstanceId = this.props.processInstanceId;
      let taskId = this.props.id;
      let handleUserId = this.props.assignee;
      let formId = this.props.formKey;
      let dataId = this.props.businessKey;
      let type = this.props.type;
      // if(type == 5){
      //   type = 0;
      // }
      let processKey = this.props.processKey;
      let category = this.props.category;
      let id = "";
      // if(type == 1){//已办
      //   id = processInstanceId;
      // }else{
      id = taskId;
      //}
      let url = "process/processDetails/" + id + "/" + formId + "/" + dataId + "/" + type + "/0/" + processInstanceId + "/meeting/" + category;
      location.hash = url;
    } else {
      this.props.updateAbleClick(true);
    }
  },
  render: function () {
    let checkIsNotComplete = function (data) { //检查是否办理完成
      if (data.type == 0) { //待办
        return true;
      }else if (data.type == 1) { //待阅
        return true;
      }else if (data.type == 2) { //已办
        if (typeof (data.processEndTime) == 'undefined' || data.processEndTime == null) {
          return true;
        } else {
          return false;
        }
      }else if (data.type == 3) { //已阅
        if (typeof (data.processEndTime) == 'undefined' || data.processEndTime == null) {
          return true;
        } else {
          return false;
        }
      } else if (data.type == 4){ //我的
        if (typeof (data.finishedTime) == 'undefined' || data.finishedTime == null) {
          return true;
        } else {
          return false;
        }
      }else if (data.type == 5) { //草稿箱
        return true;
      }
    }
    let comleteName = function (data) {
      if (data.type == 0) { //待办
        return data.name;
      } else if (data.type == 1) { //待阅
        return data.name;
      } else if (data.type == 2) { //已办
        return data.curStepName;
      } else if (data.type == 3) { //已阅
        return data.name;
      } else if (data.type == 4){ //我的
        return data.curStepName;
      } else if (data.type == 5){ //草稿箱
        return data.name;
      }
    }
    let assigneeName = function (data) {
      if (data.type == 0) { //待办
        return data.startUserName;
      } else if (data.type == 1) { //待阅
        return data.startUserName;
      } else if (data.type == 2) { //已办
        return data.curUserName;
      } else if (data.type == 3) { //已阅
        return data.assigneeName;
      } else if (data.type == 4){ //我的
        return data.curUserName;
      } else if (data.type == 5){ //草稿箱
        return data.startUserName;
      }
    }

    let formatTime = function (data) {
      if (data.type == 0) { //待办
        return data.createTime.substring(5,16);
      } else if (data.type == 1) { //待阅
        return data.createTime.substring(5,16);
      } else if (data.type == 2) { //已办
        return data.createTime.substring(5,16);
      } else if (data.type == 3) { //已阅
        return data.endTime.substring(5,16);
      } else if (data.type == 4){ //我的
        return data.createTime.substring(5,16);
      } else if (data.type == 5){ //草稿箱
        return data.createTime.substring(5,16);
      }
    }
    return <div>
      {/* <Group.List lineIndent={80}>
        <div className="dd-t-list-wrap text-omit" >
          <HBox vAlign="center" onClick={this.clickList.bind(this)}>
            <HBox flex={1} className="t-FBAC">
              <Box className="dd-t-list-text-content" flex={1}>
                <HBox className="t-list-titlet-LH1_4" vAlign="center">
                  <Box className={this.props.urgency == '1' && this.props.type == 0 ?'t-BCred t-FCf t-WH18 t-FS14 t-FAC t-MR4 t-LH1_2 t-R3':'t-DN'}>急</Box>
                  <Box className="t-omit" flex={1}>{this.props.title}</Box>
                </HBox>
                <div className="dd-t-list-time t-FBAC">
                  <Time className="t-MR4" />
                  <span className="t-list-text t-omit t-MR12">{formatTime(this.props)}</span>
                  <span className={this.props.type==0?'t-list-text t-FCc t-omit t-MR4':'t-DN'}>{assigneeName(this.props)}</span><span className={this.props.type==0?'t-list-text t-FCgreen t-omit t-MR4':'t-DN'}>申请</span><i className={checkIsNotComplete(this.props) ? 'iconfont icon-approval t-FCoranger t-MR4' : 'iconfont icon-approval t-FCgreen t-MR4'} style={{ fontSize: 14 }}></i><span className={checkIsNotComplete(this.props) ? 't-list-text t-FCoranger t-omit t-MR4' : 't-list-text t-FCgreen t-omit t-MR4'}>{checkIsNotComplete(this.props) ?comleteName(this.props) : '办理完毕'}</span><span className={checkIsNotComplete(this.props) && this.props.type != 0 ? 't-list-text t-MR4 t-FCoranger t-omit' : 't-DN'}>{assigneeName(this.props)}</span>
                </div>
              </Box>
            </HBox>
            <Box>
              <AngleRight width={20} fill="#ccc" className="demo-t-list-arrow" />
            </Box>
          </HBox>
        </div>
      </Group.List> */}

      <HBox className="t-BCf t-P16 t-PR12 dd-bottom-border" onClick={this.clickList.bind(this)}>
        <Box flex={1}>
          <div className="t-omit t-FC3 t-FS16 t-LH1_3 t-MR8">
            <i className={this.props.urgency == '1' && this.props.type == 0 ?'t-BCred t-FCf t-WH18 t-FS14 t-FAC t-MR4 t-LH1_2 t-R3':'t-DN'}>急</i>
            {this.props.title}
          </div>
          <HBox className="t-FCddfontblue-40 t-LH1_3 t-PT8 t-FS14" vAlign="center">
            <HBox vAlign="center">
              <Box><i className="iconfont icon-time t-MR4 t-FS14"></i></Box>
              <Box><span className="t-omit t-MR26">{formatTime(this.props)}</span></Box>
            </HBox>
            <HBox flex={1} vAlign="center">
              <Box><span className={this.props.type==0?'t-list-text t-FCc t-omit t-MR4':'t-DN'}>{assigneeName(this.props)}</span></Box>
              <Box><span className={this.props.type==0?'t-list-text t-FCgreen t-omit t-MR4':'t-DN'}>申请</span></Box>
              <Box><i className={checkIsNotComplete(this.props) ? 'iconfont icon-approval t-FCoranger t-MR4' : 'iconfont icon-approval t-FCgreen t-MR4'} style={{ fontSize: 14 }}></i></Box>
              <Box><span className={checkIsNotComplete(this.props) ? 't-list-text t-FCoranger t-omit t-MR4' : 't-list-text t-FCgreen t-omit t-MR4'}>{checkIsNotComplete(this.props) ?comleteName(this.props) : '办理完毕'}</span></Box>
              <Box><span className={checkIsNotComplete(this.props) && this.props.type != 0 ? 't-list-text t-MR4 t-FCoranger t-omit' : 't-DN'}>{assigneeName(this.props)}</span></Box>
            </HBox>
          </HBox>
        </Box>
        <Box>
          <AngleRight width={20} fill="#ccc" className="demo-t-list-arrow" />
        </Box>
      </HBox>
    </div>;
  }
});

const ItemCollapse = React.createClass({
  getInitialState: function () {//组件相关的状态对象
    return {
      show: false,
      itemList: []
    }
  },
  clickList: function (item) {
    if (this.props.ableClick) {
      let processInstanceId = item.processInstanceId;
      let taskId = item.id;
      //let handleUserId = item.assignee;
      let formId = item.formKey;
      let dataId = item.businessKey;
      let type = this.props.type;
      //let processKey = this.props.processKey;
      let category = item.category;
      let id = "";
      // if(type == 1){//已办
      //   id = processInstanceId;
      // }else{
      id = taskId;
      //}
      let url = "process/processDetails/" + id + "/" + formId + "/" + dataId + "/" + type + "/0/" + processInstanceId + "/meeting/" + category;
      location.hash = url;
    } else {
      this.props.updateAbleClick(true);
    }
  },
  clickList2: function (show) {
    let t = this;
    if(!show){
      DB.SomeModuleAPI.getDoneTaskListByProcessId({
        processInstanceId:this.props.processInstanceId,
        module:"meeting",
      })
      .then((content) => {
        t.setState({
          itemList:content.list,
          show: !show
        })
      }).catch((error) => {
        console.error(error);
      });
    }else{
      t.setState({
        itemList:[],
        show: !show
      })
    }
  },
  render: function () {
    let checkIsNotComplete = function (data) { //检查是否办理完成
      if (data.type == 0) { //待办
        return true;
      } else if (data.type == 1) { //待阅
        return true;
      } else if (data.type == 2) { //已办
        if (typeof (data.processEndTime) == 'undefined' || data.processEndTime == null) {
          return true;
        } else {
          return false;
        }
      } else if (data.type == 3) { //已阅
        if (typeof (data.processEndTime) == 'undefined' || data.processEndTime == null) {
          return true;
        } else {
          return false;
        }
      } else if (data.type == 4){ //我的
        if (typeof (data.finishedTime) == 'undefined' || data.finishedTime == null) {
          return true;
        } else {
          return false;
        }
      } else if (data.type == 5) { //草稿箱
        return true;
      }
    }

    //主列表
    let comleteName = function (data) {
      if (data.type == 0) { //待办
        return data.name;
      } else if (data.type == 1) { //待阅
        return data.name;
      } else if (data.type == 2) { //已办
        return data.curStepName;
      } else if (data.type == 3) { //已阅
        return data.name;
      } else if (data.type == 4) { //我的
        return data.curStepName;
      } else if (data.type == 5) { //草稿箱
        return data.name;
      }
    }

    //子列表
    let comleteName2 = function (data,type) {
      if (type == 0) { //待办
        return data.name;
      } else if (type == 1) { //待阅
        return data.name;
      } else if (type == 2) { //已办
        return data.name;
      } else if (type == 3) { //已阅
        return data.name;
      } else if (type ==4) { //我的
        return data.curStepName;
      } else if (type == 5) { //草稿箱
        return data.name;
      }
    }
     //主列表
    let assigneeName = function (data) {
      if (data.type == 0) { //待办
        return data.startUserName;
      } else if (data.type == 1) { //待阅
        return data.startUserName;
      } else if (data.type == 2) { //已办
        return data.curUserName;
      } else if (data.type == 3) { //已阅
        return data.assigneeName;
      } else if (data.type == 4) { //我的
        return data.curUserName;
      } else if (data.type == 5) { //草稿箱
        return data.startUserName;
      }
    }

    //主列表
    let formatTime = function (data) {
      if (data.type == 0) { //待办
        return data.createTime.substring(5,16);
      } else if (data.type == 1) { //待阅
        return data.createTime.substring(5,16);
      } else if (data.type == 2) { //已办
        return data.createTime.substring(5,16);
      } else if (data.type == 3) { //已阅
        return data.endTime.substring(5,16);
      } else if (data.type == 4) { //我的
        return data.createTime.substring(5,16);
      } else if (data.type == 5) { //草稿箱
        return data.createTime.substring(5,16);
      }
    }

     //子列表
    let formatTime2 = function (data,type) {
      if (type == 0) { //待办
        return data.createTime.substring(5,16);
      } else if (type == 1) { //待阅
        return data.createTime.substring(5,16);
      } else if (type == 2) { //已办
        return data.endTime.substring(5,16);
      } else if (type == 3) { //已阅
        return data.endTime.substring(5,16);
      } else if (type == 4) { //我的
        return data.createTime.substring(5,16);
      } else if (type == 5) { //草稿箱
        return data.createTime.substring(5,16);
      }
    }

     //子列表
     let formatAction = function (data) {
      if (data.action == 'submit') { 
        return "通过";;
      } else if (data.action == 'transfer') { 
        return "转交";
      } else if (data.action == 'back') { 
        return "驳回";
      } else if (data.action == 'jump') { 
        return "跳转";
      } else if (data.action == 'end') { 
        return "结束";
      } else if (data.action == 'cancel') {
        return "取消";
      } else if(data.action == 'finish'){
        return "完成";
      }
    }

    return <div className="t-BCf dd-bottom-border">
        {/* <div className="dd-t-list-wrap text-omit" > */}
          {/* <HBox vAlign="center" onClick={this.clickList2.bind(this, this.state.show)}>
            <HBox flex={1} className="t-FBAC">
              <Box className="dd-t-list-text-content" flex={1}>
                <div className="t-FBH t-FBAC t-list-titlet-LH1_4">
                  <div className="t-FB1 t-omit">{this.props.title}</div>
                </div>
                <div className="dd-t-list-time t-FBAC">
                  <Time className="t-MR4" />
                  <span className="t-list-text t-omit t-MR12">{formatTime(this.props)}</span>
                  <i className={checkIsNotComplete(this.props) ? 'iconfont icon-approval t-FCoranger t-MR4' : 'iconfont icon-approval t-FCgreen t-MR4'} style={{ fontSize: 14 }}></i><span className={checkIsNotComplete(this.props) ? 't-list-text t-FCoranger t-omit t-MR4' : 't-list-text t-FCgreen t-omit t-MR4'}>{checkIsNotComplete(this.props) ? comleteName(this.props) : '办理完毕'}</span><span className={checkIsNotComplete(this.props) ? 't-list-text t-MR4 t-FCoranger t-omit' : 't-DN'}>{assigneeName(this.props)}</span>
                </div>
              </Box>
            </HBox>
            <Box>
              <i className={this.state.show ? "iconfont icon-arrow-up t-FS16 t-FCc t-LH42" : "iconfont icon-arrow-down t-FS16 t-FCc t-LH42"}></i>
            </Box>
          </HBox> */}

          <HBox className="t-BCf t-P16 t-PR12 " onClick={this.clickList2.bind(this, this.state.show)}>
            <Box flex={1}>
              <div className="t-omit t-FC3 t-FS16 t-LH1_3 t-MR8">
                {this.props.title}
              </div>
              <HBox className="t-FCddfontblue-40 t-LH1_3 t-PT8 t-FS14" vAlign="center">
                <HBox vAlign="center">
                  <Box><i className="iconfont icon-time t-MR4 t-FS14"></i></Box>
                  <Box><span className="t-omit t-MR26">{formatTime(this.props)}</span></Box>
                </HBox>
                <HBox flex={1} vAlign="center">
                  <Box><i className={checkIsNotComplete(this.props) ? 'iconfont icon-approval t-FCoranger t-MR4' : 'iconfont icon-approval t-FCgreen t-MR4'} style={{ fontSize: 14 }}></i></Box>
                  <Box><span className={checkIsNotComplete(this.props) ? 't-list-text t-FCoranger t-omit t-MR4' : 't-list-text t-FCgreen t-omit t-MR4'}>{checkIsNotComplete(this.props) ? comleteName(this.props) : '办理完毕'}</span></Box>
                  <Box><span className={checkIsNotComplete(this.props) ? 't-list-text t-MR4 t-FCoranger t-omit' : 't-DN'}>{assigneeName(this.props)}</span></Box>
                </HBox>
              </HBox>
            </Box>
            <Box>
              <i className={this.state.show ? "iconfont icon-arrow-up t-FS16 t-FCc t-LH42" : "iconfont icon-arrow-down t-FS16 t-FCc t-LH42"}></i>
            </Box>
          </HBox>
        {/* </div> */}
        <div className={this.state.shows ? "t-DN" : ""}>
          {
            this.state.itemList.map(function (item, i) {
              return (
                <div className="dd-t-list-wrap t-PL0 t-ML67 dd-top-border"  onClick={this.clickList.bind(this,item)}>
                  <HBox flex={1} vAlign="center">
                    <Box className="dd-t-list-text-content" flex={1}>
                    <div className="t-FBH t-FBAC t-list-titlet-LH1_4">
                      <div className="t-FB1 t-omit">{item.title}</div>
                    </div>
                      <div className="dd-t-list-time t-FBAC t-FBH">
                        <i className="iconfont icon-time t-FCc t-MR4 t-FS14"></i>
                        <span className="t-list-text t-omit t-MR12">{formatTime2(item,this.props.type)}</span>
                        <i className="iconfont icon-approval t-MR4" style={{ fontSize: 14 }}></i>
                        <span className="t-list-text t-omit t-MR4"> {comleteName2(item,this.props.type)}</span>
                        <span className="t-list-text t-MR4 t-omit">{formatAction(item)}</span>
                      </div>
                    </Box>
                  </HBox>
                </div>
              )
            }.bind(this))
          }
        </div>
    </div>;
  }
});


let iconIndex = 2;
export default class PageHome extends Component {

  constructor(props) {
    super(props);
    let t = this;
    let type = this.props.params.type;
    if(!type){
      type = "0";
    }

    //关闭加载页的遮罩效果
    $(".loading-containter").hide();

    //禁用ios弹性事件
    dd.ui.webViewBounce.disable();

    //是否需要底部tab页
    var hasBottomTab =  document.getElementById("hasBottomTab").value;

    let userId = document.getElementById("userHiddenId").value;

    $("#App").removeAttr("style");
    Popup.hide();
    Dialog.hide();

    //获取内容显示区域高度
    var winHeight = getScrollHigh(1, 1, hasBottomTab);
    let tabIndex = document.getElementById("sendTabIndex").value;
    if (tabIndex == '') {
      tabIndex = type;
    } else {
      type = tabIndex;
    }

    this.state = {
      userId: userId,
      activeIndex: 0,
      activeDealWithIndex: type,
      winHeight: winHeight,
      ableClick: true,
      search0: '',
      search1: '',
      search2: '',
      search3: '',
      search4: '',
      search5: '',
      noDataTip0:'暂无数据',
      noDataTip1:'暂无数据',
      noDataTip2:'暂无数据',
      noDataTip3:'暂无数据',
      noDataTip4:'暂无数据',
      noDataTip5:'暂无数据',
      hasBottomTab: hasBottomTab
    };

    var isHelpNew = 1;
    dd.util.domainStorage.getItem({ //帮助按钮
      name:'meeting_helpNew_'+userId , // 存储信息的key值
      onSuccess : function(info) {
        var helpNew = info.value;
        if( typeof(helpNew) == 'undefined' || helpNew == '' ){
          isHelpNew = 2;
        }
        //初始化按钮
        t.initButton(isHelpNew);
      },
      onFail : function(err) {
        //alert(JSON.stringify(err));
      }
    });
  }

  //初始化按钮
  initButton(isHelpNew){
    //设置帮助
    /*dd.biz.navigation.setIcon({
      showIcon : true,//是否显示icon
      iconIndex : isHelpNew,//显示的iconIndex,如上图
      onSuccess : function(result) {
        location.hash='help/help_index';
      },
      onFail : function(err) {
        //jsapi调用失败将会回调此函数
      }
    });*/
  }

  componentDidMount() {
    var page_title = "办理";
    $("title").text(page_title);
    //获取首页信息
    let t = this;
    var thirdMenuType = getLoginUserInfo().thirdMenuType;
    if(thirdMenuType == 'DING'){
      dd.biz.navigation.setTitle({
          title : page_title,//控制标题文本，空字符串表示显示默认文本
          onSuccess : function(result) {},
          onFail : function(err) {}
      });
    }else if(thirdMenuType =='MH'){
      !!emp&&emp.window.setTitle({
          title: {
              text: page_title,
              icon: '',
              actionmenu: {}
          },
      });
    }
    searchBarLimit(20);
  }

  //分页列表请求前
  beforeFetch0(data, form) {
    this.setState({
      ableClick: false
    });
    let search = form.value;
    if (search == undefined) {
      if (form == 'top') {
        this.setState({ ableClick: false });
      }
      data.search = this.state.search0;
    } else {
      data.search = form.value;
    }
    return data;
  }

  //分页列表请求前
  beforeFetch1(data, form) {
    this.setState({
      ableClick: false
    });
    let search = form.value;
    if (search == undefined) {
      if (form == 'top') {
        this.setState({ ableClick: false });
      }
      data.title = this.state.search1;
    } else {
      data.title = form.value;
    }
    return data;
  }

  //分页列表请求前
  beforeFetch2(data, form) {
    this.setState({
      ableClick: false
    });
    let search = form.value;
    if (search == undefined) {
      if (form == 'top') {
        this.setState({ ableClick: false });
      }
      data.search = this.state.search2;
    } else {
      data.search = form.value;
    }
    return data;
  }

  //分页列表请求前
  beforeFetch3(data, form) {
    this.setState({
      ableClick: false
    });
    let search = form.value;
    if (search == undefined) {
      if (form == 'top') {
        this.setState({ ableClick: false });
      }
      data.title = this.state.search3;
    } else {
      data.title = form.value;
    }
    return data;
  }

  //分页列表请求前
  beforeFetch4(data, form) {
    this.setState({
      ableClick: false
    });
    let search = form.value;
    if (search == undefined) {
      data.search = this.state.search4;
    } else {
      data.search = form.value;
    }
    return data;
  }

  //分页列表请求前
  beforeFetch5(data, form) {
    this.setState({
      ableClick: false
    });
    let search = form.value;
    if (search == undefined) {
      if (form == 'top') {
        this.setState({ ableClick: false });
      }
      data.title = this.state.search5;
    } else {
      data.title = form.value;
    }
    return data;
  }

  processData(data) {
    this.setState({
      ableClick: true
    });
    return data;
  }

  onSearch(no, value) {
    let t = this;
    if (no == 0) {
      t.setState({
        search0: value,
        noDataTip0:'无搜索结果'
      });
      t.refs.noDealWith0_ref.fetchData({
        value: value
      });
    } else if (no == 1) {
      t.setState({
        search1: value,
        noDataTip1:'无搜索结果'
      });
      t.refs.noDealWith1_ref.fetchData({
        value: value
      });
    } else if (no == 2) {
      t.setState({
        search2: value,
        noDataTip2:'无搜索结果'
      });
      t.refs.noDealWith2_ref.fetchData({
        value: value
      });
    } else if (no == 3) {
      t.setState({
        search3: value,
        noDataTip3:'无搜索结果'
      });
      t.refs.noDealWith3_ref.fetchData({
        value: value
      });
    } else if (no == 4) {
      t.setState({
        search4: value,
        noDataTip4:'无搜索结果'
      });
      t.refs.noDealWith4_ref.fetchData({
        value: value
      });
    } else if (no == 5) {
      t.setState({
        search5: value,
        noDataTip5:'无搜索结果'
      });
      t.refs.noDealWith5_ref.fetchData({
        value: value
      });
    }
  }

  onExit(no) {
    var value = '';
    let t = this;
    if (no == 0) {
      t.setState({
        search0: value,
        noDataTip0:'暂无数据'
      });
      t.refs.noDealWith0_ref.fetchData({
        value: value
      });
    } else if (no == 1) {
      t.setState({
        search1: value,
        noDataTip1:'暂无数据'
      });
      t.refs.noDealWith1_ref.fetchData({
        value: value
      });
    } else if (no == 2) {
      t.setState({
        search2: value,
        noDataTip2:'暂无数据'
      });
      t.refs.noDealWith2_ref.fetchData({
        value: value
      });
    } else if (no == 3) {
      t.setState({
        search3: value,
        noDataTip3:'暂无数据'
      });
      t.refs.noDealWith3_ref.fetchData({
        value: value
      });
    } else if (no == 4) {
      t.setState({
        search4: value,
        noDataTip4:'暂无数据'
      });
      t.refs.noDealWith4_ref.fetchData({
        value: value
      });
    } else if (no == 5) {
      t.setState({
        search5: value,
        noDataTip5:'暂无数据'
      });
      t.refs.noDealWith5_ref.fetchData({
        value: value
      });
    }
  }

  handleChangeTab(obj) {
    document.getElementById("sendTabIndex").value = obj.active;
    this.setState({ activeDealWithIndex: obj.active });
    searchBarLimit(20);
  }

  //更新可点击状态
  updateAbleClick(boolean) {
    this.setState({
      ableClick: boolean
    });
  }

  //点击批量
  clickBatch(boolean){
    this.setState({
      isBatch: !boolean
    });
  }

  clickBatchButton(){
    let t = this;
    //遍历循环选中
    if(this.state.activeDealWithIndex == 0){

      var taskIds = "";
      var processInstanceIds = "";
      let taskId = '';
      $(".checked").map(function(index,item){
        taskIds += $(item).attr("data-taskid")+",";
        processInstanceIds += $(item).attr("data-processInstanceid")+",";

        if(index == 0){
          taskId = $(item).attr("data-taskid");
        }
      });

      if(taskIds){
        taskIds = taskIds.substring(0,taskIds.length-1);
        processInstanceIds = processInstanceIds.substring(0,processInstanceIds.length-1);
      }else{
        Toast.show({
          type: 'error',
          content: '请选择记录'
        });
        return;
      }
      DB.FlowModuleAPI.getUndoTaskInfo({
        taskId:taskId,
      }).then((taskContent) => {
        let buttonCodes = taskContent.buttons;
        let tasktype = taskContent.tasktype;
        if(buttonCodes.indexOf('BASE_SUMBIT')!=-1 && tasktype!='radom'){
          //是否有批示意见
          let hasCommentField = taskContent.hasCommentField;
          if(!hasCommentField){
            hasCommentField='0';
          }

          //紧急
          let urgent = taskContent.urgency;
          if(!urgent){
            urgent = '0';
          }

          //是否有锁
          let lock = taskContent.lock;

          //流程编码
          let code = taskContent.code;

          //是否是起点
          let isStart = taskContent.isStart==true?"1":"0";

          location.hash='meeting/meetingBatchSubmit/'+taskIds+"/"+processInstanceIds+"/1/"+code+"/"+hasCommentField+"/"+urgent+"/"+isStart;
        }else{
          Toast.show({
            type: 'error',
            content: '当前勾选的任务中，含有不支持批量通过的任务！',
          });
        }
      }).catch((error) => {
        Toast.show({
          type: 'error',
          content: error.errorMsg,
        });
      });

    }else if(this.state.activeDealWithIndex == 1){//待阅
      var taskIds = "";
      $(".checked").map(function(index,item){
        taskIds += $(item).attr("data-taskid")+",";
      });

      if(taskIds){
        taskIds = taskIds.substring(0,taskIds.length-1);
      }else{
        Toast.show({
          type: 'error',
          content: '请选择记录'
        });
        return;
      }
      DB.DocumentModuleAPI.readCompleteTaskBatch({
        taskIds:taskIds,
      }).then((content) => {
        Toast.show({
          type: 'success',
          content: '已阅成功'
        });
        t.setState({
          isBatch:false
        });
        t.refs.noDealWith2_ref.fetchData({
          value: t.state.search2
        });
      }).catch((error) => {
        Toast.show({
          type: 'error',
          content: error.errorMsg,
        });
      });
    }

  }

  render() {

    const tabBarStyle = {};
    const t = this;
    let winHeightStyle = { height: this.state.winHeight };
    const props = {
      placeholder: "请输入标题搜索",
      locale: 'zh_CN',
      instantSearch: false,
      hasHistory: true,
      searchDelay: 450,
      onEnter: () => { console.log('enter'); },
      onChange: (value) => {
        console.log(`Typing>>${value}`);
      }
    };
    return (
      <div className="scrollList">
        <Tab destroyInactiveTabPane={false} activeKey={this.state.activeDealWithIndex} onChange={t.handleChangeTab.bind(t)}>
          <Tab.Item title={"待办"}>
            <HBox vAlign="center" className="t-BCf">
              <Box flex={1}>
                <SearchBar {...props} onSearch={this.onSearch.bind(this, 0)} 
                  onExit={this.onExit.bind(this, 0)} />
              </Box>
            </HBox>
            <div  style={winHeightStyle} >
              <ScrollList
                url={URLS.getProcessInfoNoDoList}
                dataType="json"
                pageSize={10}
                beforeFetch={this.beforeFetch0.bind(this)}
                processData={this.processData.bind(this)}
                noDataTip={this.state.noDataTip0}
                ref='noDealWith0_ref'
                noDataImage={nodataIcon}
                currentPageKey="page">
                <Item type="0" ableClick={this.state.ableClick} updateAbleClick={this.updateAbleClick.bind(this)}/>
              </ScrollList>
            </div>
          </Tab.Item>
          <Tab.Item title={"待阅"} >
            <HBox vAlign="center" className="t-BCf">
              <Box flex={1}>
                <SearchBar {...props} onSearch={this.onSearch.bind(this, 1)} onExit={this.onExit.bind(this, 1)} />
              </Box>
              {/*<Box className={this.state.isBatch?"t-FCc t-PR16":"t-FCddblue t-PR16"} isBatch={this.state.isBatch} onClick={t.clickBatch.bind(t,this.state.isBatch)}>
                批量
              </Box>*/}
            </HBox>
            <div style={winHeightStyle} >
              <ScrollList
                url={URLS.getProcessInfoUnReadList}
                dataType="json"
                pageSize={10}
                beforeFetch={this.beforeFetch1.bind(this)}
                processData={this.processData.bind(this)}
                noDataTip={this.state.noDataTip1}
                ref='noDealWith1_ref'
                noDataImage={nodataIcon}
                currentPageKey="page"
              >
                <Item type="1" ableClick={this.state.ableClick} isBatch={this.state.isBatch} updateAbleClick={this.updateAbleClick.bind(this)} />
              </ScrollList>
            </div>
          </Tab.Item>
          <Tab.Item title="已办" >
            <SearchBar {...props} onSearch={this.onSearch.bind(this, 2)} onExit={this.onExit.bind(this, 2)} />
            <div style={winHeightStyle} >
              <ScrollList
                url={URLS.getProcessInfoDoneList}
                dataType="json"
                pageSize={10}
                beforeFetch={this.beforeFetch2.bind(this)}
                processData={this.processData.bind(this)}
                noDataTip={this.state.noDataTip2}
                ref='noDealWith2_ref'
                noDataImage={nodataIcon}
                currentPageKey="page">
                <ItemCollapse type="2" ableClick={this.state.ableClick} updateAbleClick={this.updateAbleClick.bind(this)} />
              </ScrollList>
            </div>
          </Tab.Item>
          <Tab.Item title="已阅" >
            <SearchBar {...props} onSearch={this.onSearch.bind(this, 3)} onExit={this.onExit.bind(this, 3)} />
            <div style={winHeightStyle} >
              <ScrollList
                url={URLS.getProcessInfoReadList}
                dataType="json"
                pageSize={10}
                beforeFetch={this.beforeFetch3.bind(this)}
                processData={this.processData.bind(this)}
                noDataTip={this.state.noDataTip3}
                ref='noDealWith3_ref'
                noDataImage={nodataIcon}
                currentPageKey="page"
              >
                <Item type="3" ableClick={this.state.ableClick} isBatch={this.state.isBatch} updateAbleClick={this.updateAbleClick.bind(this)} />
              </ScrollList>
            </div>
          </Tab.Item>
          <Tab.Item title={"我的"} >
            <SearchBar {...props} onSearch={this.onSearch.bind(this, 4)} onExit={this.onExit.bind(this, 4)} />
            <div  style={winHeightStyle} >
              <ScrollList
                url={URLS.getProcessInfoMyList}
                dataType="json"
                pageSize={10}
                beforeFetch={this.beforeFetch4.bind(this)}
                processData={this.processData.bind(this)}
                noDataTip={this.state.noDataTip4}
                ref='noDealWith4_ref'
                noDataImage={nodataIcon}
                currentPageKey="page">
                <Item type="4" ableClick={this.state.ableClick} updateAbleClick={this.updateAbleClick.bind(this)} />
              </ScrollList>
            </div>
          </Tab.Item>
          <Tab.Item title={"草稿箱"} >
            <SearchBar {...props} onSearch={this.onSearch.bind(this, 5)} onExit={this.onExit.bind(this, 5)} />
            <div style={winHeightStyle} >
              <ScrollList
                url={URLS.getProcessInfoDraftList}
                dataType="json"
                pageSize={10}
                beforeFetch={this.beforeFetch5.bind(this)}
                processData={this.processData.bind(this)}
                noDataTip={this.state.noDataTip5}
                ref='noDealWith5_ref'
                noDataImage={nodataIcon}
                currentPageKey="page">
                <Item type="5" ableClick={this.state.ableClick} updateAbleClick={this.updateAbleClick.bind(this)} />
              </ScrollList>
            </div>
          </Tab.Item>
        </Tab>
        <div className={this.state.isBatch?"t-P0 t-bottom-fixed":"t-DN"}>
          <Button.Group>
            <Button type="primary" display="banner"
                    onClick={this.clickBatchButton.bind(this)}>{this.state.activeDealWithIndex==0?'通过':'已阅'}</Button>
            <Button type="secondary" display="banner" onClick={this.clickBatch.bind(this,true)}>取消</Button>
          </Button.Group>
        </div>
        <MyTabBar activeIndex={3} />
      </div>
    );
  }
}


